package com.coda.controller;

import com.coda.common.PageResult;
import com.coda.common.Result;
import com.coda.dto.PageDto;
import com.coda.entity.InStore;
import com.coda.entity.Store;
import com.coda.service.InStoreService;
import com.coda.service.StoreService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/warehouse/instore")
@RestController
@Api("出库相关接口")
public class InStoreController {

    @Autowired
    private StoreService StoreService;
    @Autowired
    private InStoreService inStoreService;

    /**
     * 显示仓库列表
     */
    @GetMapping("/store-list")
    @ApiOperation("")
    public Result getStoreList(){
        List<Store> storeList = StoreService.getStoreList();
        return Result.ok(storeList);
    }

    /**
     * 分页查询入库列表
     */
    @GetMapping("/instore-page-list")
    @ApiOperation("分页查询入库列表")
    public Result getInStorePage(PageDto pageDto,  InStore inStore){
        PageResult pageResult  = inStoreService.getInstorePage(pageDto,inStore);
        return Result.ok(pageResult);
    }
    /**
     * 确定入库
     */
    @PutMapping("/instore-confirm")
    @ApiOperation("确定入库")
    public Result isStoreOk(@RequestBody InStore inStore){
        inStoreService.isStoreOk(inStore);
        return Result.ok("入库成功");
    }
}
